import { computed, ref } from "vue"

export type UploadType = "File" | "Folder"

/**
 * 测量工具类型
 */
export enum MeasuringType {
  // 点坐标
  POSITION = "1",
  // 距离
  DISTANCE = "2"
}

export enum DrawingTypeEnum {
  Point,
  Polyline,
  Rectangle,
  Polygon,
  Circle,
  Ellipse,
  Curve
}

export const ControlObjectMap = {
  [DrawingTypeEnum.Point]: "WayPoint",
  [DrawingTypeEnum.Polyline]: "Route",
  [DrawingTypeEnum.Rectangle]: "Rectangle",
  [DrawingTypeEnum.Polygon]: "Polygon",
  [DrawingTypeEnum.Circle]: "Circle",
  [DrawingTypeEnum.Ellipse]: "Ellipse"
  // [DrawingTypeEnum.Curve]: "Curve"
}

/**
 * 控制对象类型
 */
export const ControlObjects = [
  { name: "路径点", value: DrawingTypeEnum.Point, type: "WayPoint" },
  { name: "路径", value: DrawingTypeEnum.Polyline, type: "Route" },
  { name: "矩形", value: DrawingTypeEnum.Rectangle, type: "Rectangle" },
  { name: "区域", value: DrawingTypeEnum.Polygon, type: "Polygon" },
  { name: "圆形", value: DrawingTypeEnum.Circle, type: "Circle" },
  { name: "椭圆形", value: DrawingTypeEnum.Ellipse, type: "Ellipse" }
]

/** 任务统计类型 */
export enum TaskStaticsTypeEnum {
  CREATED,
  RUNNING,
  FINISHED,
  ERROR,
  STOPPED
}

/** 表单类型 */
export enum FormTypeEnum {
  CREATE,
  EDIT,
  VIEW
}
export type TASK_MODE = "Train" | "Inference"
export const taskModeOptions = ref<{ value: TASK_MODE, name: string }[]>([
  { name: "训练", value: "Train" },
  { name: "推演", value: "Inference" }
])
export const taskModeMap = computed<{ [propName: string]: string }>(
  () => {
    return taskModeOptions.value.reduce(
      (acc: { [propName: string]: string }, curr) => {
        acc[curr.value] = curr.name
        return acc
      },
      {}
    )
  }
)
// 任务状态
export const taskStatusOptions = ref<{ value: TaskStaticsTypeEnum, name: string }[]>([
  { value: TaskStaticsTypeEnum.CREATED, name: "创建" },
  { value: TaskStaticsTypeEnum.RUNNING, name: "运行中" },
  { value: TaskStaticsTypeEnum.FINISHED, name: "结束" },
  { value: TaskStaticsTypeEnum.ERROR, name: "错误" },
  { value: TaskStaticsTypeEnum.STOPPED, name: "暂停" }
])
export const taskStatusMap = computed<{ [propName: string]: string }>(
  () => {
    return taskStatusOptions.value.reduce(
      (acc: { [propName: string]: string }, curr) => {
        acc[curr.value] = curr.name
        return acc
      },
      {}
    )
  }
)

export type TASK_EVAL_INDEX =
  | "perception"
  | "cognition"
  | "decision"
  | "action"
/** 评估指标 */
export const evalIndexOptions = ref<{ value: string, name: string }[]>([
  { name: "感知", value: "perception" },
  { name: "认知", value: "cognition" },
  { name: "决策", value: "decision" },
  { name: "行动", value: "action" }
])

/** 支持红蓝方阵营 */
export enum AGENT_SUPPORT_SIDE {
  RED = 1,
  BLUE = 2,
  OTHER = 3
}

export const agentSupportSide = ref<{ value: string, name: string }[]>([
  { name: "红方", value: "1" },
  { name: "蓝方", value: "2" },
  { name: "红方、蓝方", value: "3" }
])
export const agentSupportSideMap = computed<{ [propName: string]: string }>(
  () => {
    return agentSupportSide.value.reduce(
      (acc: { [propName: string]: string }, curr) => {
        acc[curr.value] = curr.name
        return acc
      },
      {}
    )
  }
)

export type ModelType = "ESR" | "Sensor" | "Model" | "WeaponMount" | "Behave"

/** 模型类型 */
export const ModelTypeOps = ref<{ value: ModelType, name: string }[]>([
  { name: "状态池", value: "ESR" },
  { name: "传感器", value: "Sensor" },
  { name: "模型", value: "Model" },
  { name: "武器", value: "WeaponMount" },
  { name: "行为树", value: "Behave" }
])

export enum RecordTypeEnum {
  Base = "1",
  Array = "2"
}

export enum BSDataTypeEnum {
  Base = "base",
  Enum = "enum",
  Class = "class",
  Element = "element"
}
// 结构类型
export const dataTypeOptions = ref<{ value: BSDataTypeEnum, name: string }[]>([
  { value: BSDataTypeEnum.Base, name: "基本结构" },
  { value: BSDataTypeEnum.Enum, name: "枚举" },
  { value: BSDataTypeEnum.Class, name: "结构体" },
  { value: BSDataTypeEnum.Element, name: "元素" }
])
export const dataTypeTextMap = computed<{ [propName: string]: string }>(
  () => {
    return dataTypeOptions.value.reduce(
      (acc: { [propName: string]: string }, curr) => {
        acc[curr.value] = curr.name
        return acc
      },
      {}
    )
  }
)